package no.progark.views;

import no.progark.helikopter.R;
import no.progark.pattern.PingPongGame;
import no.progark.pong.AIController;
import no.progark.pong.Ball;
import no.progark.pong.Controller;
import no.progark.pong.Scoreboard;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.media.MediaPlayer;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;

public class PongView extends View{
	
	PingPongGame game;
	boolean firstTimeDrawBall = true;
	
	public PongView(Context context) {
		super(context);
		game = new PingPongGame(context);
		
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		if (firstTimeDrawBall) {
			game.setMeasuredHeight(this.getMeasuredHeight());
			game.setMeasuredWidth(this.getMeasuredWidth());
		}
		game.onDraw(canvas);
		invalidate();
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if(game.endOfGame()){
			game.reset();
			game.onTouch(event);
		}
		game.onTouch(event);
		return super.onTouchEvent(event);
	}
	
	
	
	
	
	
}